<template>
  <div class="login-container">
           <el-tree
              :data="data"
              show-checkbox
              node-key="id"
              :ref="demo"
              :default-checked-keys="listArray"
              :props="defaultProps"
              :node-click="commitDataFm"
              >
            </el-tree>

             <el-button type="primary"
                   @click="submit">确 定</el-button>

  </div>
</template>

<script>

export default {
  name: 'menu2',
 
  data() {
    return {
       demo:"demo",
        data: [{
          id: 1,
          label: '一级 1',
          children: [{
            id: 4,
            label: '二级 1-1',
            children: [{
              id: 9,
              label: '三级 1-1-1'
            }, {
              id: 10,
              label: '三级 1-1-2'
            }]
          }]
        }, {
          id: 2,
          label: '一级 2',
          children: [{
            id: 5,
            label: '二级 2-1'
          }, {
            id: 6,
            label: '二级 2-2'
          }]
        }, {
          id: 3,
          label: '一级 3',
          children: [{
            id: 7,
            label: '二级 3-1'
          }, {
            id: 8,
            label: '二级 3-2'
          }]
        }],
        defaultProps: {
          children: 'children',
          label: 'label'
        },
        listArray:['1','2']

    }
  },
  watch: {
  
  },
  created() {
    // window.addEventListener('storage', this.afterQRScan)
  },
  mounted() {
   
  },
  destroyed() {
    // window.removeEventListener('storage', this.afterQRScan)
  },
  methods: {
    commitDataFm(data){
      
    },
   submit () {

      let dataData= this.$refs.demo.getCheckedKeys()
        console.log('data')
       console.log(dataData)
       console.log('data')
      return 
      console.log('66666')
      let List = [];
      this.data.forEach((item) => {
        console.log('7777777')
        console.log(this.$refs[item.label])
        console.log('7777777')
        let arr = this.$refs[item.label][0].getCheckedKeys()
       
        List.push(...arr)
      })
      console.log('tttt')
      console.log(List)
      console.log('tttt')
     
    },
  
   
  
  }
}
</script>

<style lang="scss">


</style>

<style lang="scss" scoped>
     
</style>
